﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<%@ Import Namespace="CRM.Database.Model" %>
<%@ Import Namespace="CRM.Resourses" %>


<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdProfineEssentialElement";
                                        settings.KeyFieldName = "IdProfineEssentialElement";
                                        settings.CallbackRouteValues =
                                            new { Controller = "Dictionaries", Action = "ProfineEssentialElementsPartial" };
                                        settings.SettingsPager.PageSize = 20;
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.CustomerName;
                                            column.FieldName = "Name";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.OwnershipPattern;
                                            column.FieldName = "IdOwnershipPattern";
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;

                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                var col = new OwnershipsPatternsCollection();
                                                comboBoxProperties.DataSource =
                                                    col.OwnershipsPatternsList;
                                                comboBoxProperties.TextField = "LocalizedName";
                                                comboBoxProperties.ValueField = "IdOwnershipPattern";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.LegalAddress;
                                            column.FieldName = "LegalAddress";
                                            column.ColumnType = MVCxGridViewColumnType.Memo;
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.FactAddress;
                                            column.FieldName = "FactAddress";
                                            column.ColumnType = MVCxGridViewColumnType.Memo;
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.Bank;
                                            column.FieldName = "Bank";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.RSRUR;
                                            column.FieldName = "RSRUR";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.RSEUR;
                                            column.FieldName = "RSEUR";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.KS;
                                            column.FieldName = "KS";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.INN;
                                            column.FieldName = "INN";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.KPP;
                                            column.FieldName = "KPP";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.BIK;
                                            column.FieldName = "BIK";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.OKPO;
                                            column.FieldName = "OKPO";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.OKONX;
                                            column.FieldName = "OKONX";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.FIOGenDir;
                                            column.FieldName = "GenDirFull";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.FIOGenDirInRP;
                                            column.FieldName = "GenDirFullInRP";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.FIOGenDirShort;
                                            column.FieldName = "GenDirShort";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.FIOGenDirShortInRp;
                                            column.FieldName = "GenDirShortInRP";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ValidTill;
                                            column.FieldName = "ValidTill";
                                            column.ColumnType = MVCxGridViewColumnType.DateEdit;
                                        });

                                       

                                        
                                        //Добавление редактирования
                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Dictionaries", Action = "ProfineEssentialElementsPartialUpdate" };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Dictionaries", Action = "ProfineEssentialElementsPartialAdd" };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Dictionaries", Action = "ProfineEssentialElementsPartialDelete" };
                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = Unit.Percentage(100);
                                    }).Bind(Model).GetHtml();%>


